//
//  ZH_MIneAddressTableViewCell.m
//  WisdomStar
//
//  Created by zhangliwen on 2018/10/24.
//  Copyright © 2018年 zhangliwen. All rights reserved.
//

#import "ZH_MIneAddressTableViewCell.h"
@interface ZH_MIneAddressTableViewCell()
@property (nonatomic,weak)UIImageView *nameImage;
@property (nonatomic,weak)UILabel *nameLabel;
@property (nonatomic,weak)UIImageView *teleImage;
@property (nonatomic,weak)UILabel *teleLabel;
@property (nonatomic,weak)UIImageView *addressImage;
@property (nonatomic,weak)UIButton *deleButton;
@property (nonatomic,weak)UILabel *addressLabel;
@property (nonatomic,weak)UIView *lineView;
@property (nonatomic,weak)UIImageView *leftImage;
@property (nonatomic,weak)UILabel *leftLabel;
@property (nonatomic,weak)UIImageView *rightImage;
@property (nonatomic,weak)UILabel *rightLabel;
@property (nonatomic,weak)UIView *centerView;
@end
@implementation ZH_MIneAddressTableViewCell

+(instancetype)cellWithTableView:(UITableView*)tableView
{
    static NSString *ID = @"ZH_MIneAddressTableViewCell";
    ZH_MIneAddressTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if(cell == nil){
        cell = [[ZH_MIneAddressTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    return cell;
}
- (void)initDefault{
    [self unShowClickEffect];
    //    self.topShortLineImage.hidden = NO;
//    self.bottomLongLineImage.hidden = NO;
}
- (void)loadSubviewConstraints{
    [self.nameImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(FITSCALE(14));
        make.left.equalTo(self.contentView).offset(FITSCALE(11));
        make.width.mas_equalTo(FITSCALE(14));
        make.height.mas_equalTo(FITSCALE(14));
    }];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.nameImage);
        make.left.equalTo(self.nameImage.mas_right).offset(FITSCALE(7));
        make.width.mas_equalTo(FITSCALE(131));
    }];
    [self.teleImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.nameImage);
        make.left.equalTo(self.nameLabel.mas_right);
        make.width.mas_equalTo(FITSCALE(10));
        make.height.mas_equalTo(FITSCALE(14));
    }];
    [self.deleButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.nameImage);
        make.width.mas_equalTo(FITSCALE(15));
        make.height.mas_equalTo(FITSCALE(15));
        make.right.equalTo(self.contentView).offset(FITSCALE(-14));
    }];
    [self.teleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.nameImage);
        make.left.equalTo(self.teleImage.mas_right).offset(FITSCALE(7));
        make.right.equalTo(self.deleButton.mas_left);
    }];
    [self.addressImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.nameImage.mas_bottom).offset(FITSCALE(15));
        make.left.equalTo(self.contentView).offset(FITSCALE(11));
        make.width.mas_equalTo(FITSCALE(14));
        make.height.mas_equalTo(FITSCALE(14));
    }];
    [self.addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.addressImage);
        make.left.equalTo(self.addressImage.mas_right).offset(FITSCALE(7));
        make.right.equalTo(self.contentView).offset(FITSCALE(-14));
    }];
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.addressLabel.mas_bottom).offset(FITSCALE(15));
        make.left.equalTo(self.contentView).offset(FITSCALE(10));
        make.right.equalTo(self.contentView).offset(FITSCALE(-10));
        make.height.mas_equalTo(FITSCALE(1));
    }];
    [self.leftImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.lineView.mas_bottom).offset(FITSCALE(11));
        make.left.equalTo(self.contentView).offset(FITSCALE(62));
        make.width.mas_equalTo(FITSCALE(18));
        make.height.mas_equalTo(FITSCALE(18));
        make.bottom.equalTo(self.contentView).offset(FITSCALE(-12));
    }];
    [self.leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.leftImage);
        make.left.equalTo(self.leftImage.mas_right).offset(FITSCALE(7));
    }];
    [self.rightImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.lineView.mas_bottom).offset(FITSCALE(11));
        make.left.equalTo(self.contentView.mas_centerX).offset(FITSCALE(62));
        make.width.mas_equalTo(FITSCALE(18));
        make.height.mas_equalTo(FITSCALE(18));
        make.bottom.equalTo(self.contentView).offset(FITSCALE(-12));
    }];
    [self.rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.rightImage);
        make.left.equalTo(self.rightImage.mas_right).offset(FITSCALE(7));
    }];
    [self.centerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.lineView.mas_bottom);
        make.centerX.equalTo(self.contentView);
        make.bottom.equalTo(self.contentView);
        make.width.mas_equalTo(FITSCALE(1));
    }];
}
#pragma mark - getter,setter
- (UIImageView *)nameImage{
    if (!_nameImage) {
        UIImageView *image = [UIImageView createImageViewWithName:@"icon_xm"];
        [self.contentView addSubview:_nameImage = image];
    }
    return _nameImage;
}
- (UILabel *)nameLabel{
    if (!_nameLabel) {
        UILabel *label = [UILabel createLabelWithText:@"大可爱" font:kFontSize_26];
        [self.contentView addSubview:_nameLabel = label];
    }
    return _nameLabel;
}
- (UIImageView *)teleImage{
    if (!_teleImage) {
        UIImageView *image = [UIImageView createImageViewWithName:@"icon_phonenum"];
        [self.contentView addSubview:_teleImage = image];
    }
    return _teleImage;
}
- (UILabel *)teleLabel{
    if (!_teleLabel) {
        UILabel *label = [UILabel createLabelWithText:@"12312312311" font:kFontSize_26];
        [self.contentView addSubview:_teleLabel = label];
    }
    return _teleLabel;
}
- (UIImageView *)addressImage{
    if (!_addressImage) {
        UIImageView *image = [UIImageView createImageViewWithName:@"icon_xxdz"];
        [self.contentView addSubview:_addressImage = image];
    }
    return _addressImage;
}
- (UILabel *)addressLabel{
    if (!_addressLabel) {
        UILabel *label = [UILabel createLabelWithText:@"详细地址: 成都市高新区xxxx" font:kFontSize_26];
        [label lableAutoLinefeed];
        [self.contentView addSubview:_addressLabel = label];
    }
    return _addressLabel;
}
- (UIButton *)deleButton{
    if (!_deleButton) {
        UIButton *button = [UIButton createNoBgButtonWithTitle:@"" target:self action:nil];
        [button setImage:[UIImage imageNamed:@"icon_deletedz"] forState:UIControlStateNormal];
        [self.contentView addSubview:_deleButton = button];
    }
    return _deleButton;
}
- (UIView *)lineView{
    if (!_lineView) {
        UIView *view = [UIView createViewWithBackgroundColor:[UIColor colorWithHexString:@"#DFDFDF"]];
        [self.contentView addSubview:_lineView = view];
    }
    return _lineView;
}
- (UIImageView *)leftImage{
    if (!_leftImage) {
        UIImageView *image = [UIImageView createImageViewWithName:@"icon_yn"];
        [self.contentView addSubview:_leftImage = image];
    }
    return _leftImage;
}
- (UILabel *)leftLabel{
    if(!_leftLabel){
        UILabel *label = [UILabel createLabelWithText:@"选择" font:kFontSize_28];
        [self.contentView addSubview:_leftLabel = label];
    }
    return _leftLabel;
}
- (UIImageView *)rightImage{
    if (!_rightImage) {
        UIImageView *image = [UIImageView createImageViewWithName:@"icon_edit"];
        [self.contentView addSubview:_rightImage = image];
    }
    return _rightImage;
}
- (UILabel *)rightLabel{
    if(!_rightLabel){
        UILabel *label = [UILabel createLabelWithText:@"编辑" font:kFontSize_28];
        [self.contentView addSubview:_rightLabel = label];
    }
    return _rightLabel;
}
- (UIView *)centerView{
    if (!_centerView) {
        UIView *view = [UIView createViewWithBackgroundColor:[UIColor colorWithHexString:@"#DFDFDF"]];
        [self.contentView addSubview:_centerView = view];
    }
    return _centerView;
}
@end
